﻿<phone:PhoneApplicationPage
    x:Class="TaiwanPP.WP8App.fastConfig"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:toolkitPrimitives="clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:libViewModels="clr-namespace:TaiwanPP.Library.ViewModels;assembly=TaiwanPP.Library"
    xmlns:Helpers="clr-namespace:TaiwanPP.WP8App.Helpers"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True" Foreground="Black"
    shell:SystemTray.Opacity="0"
    shell:SystemTray.BackgroundColor="Transparent">
    <phone:PhoneApplicationPage.Resources>
        <Helpers:connectivitystringConverter x:Key="connectivitystringConverter"/>
        <Helpers:filterConverter x:Key="filterConverter"/>
        <Style x:Key="FixedToggleSwitchButtonStyle" TargetType="toolkitPrimitives:ToggleSwitchButton">
            <Setter Property="Foreground" Value="#000000"/>
            <Setter Property="Background" Value="#FFFFFF"/>
            <Setter Property="IsTabStop" Value="False"/>
            <Setter Property="SwitchForeground" Value="#000000"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="toolkitPrimitives:ToggleSwitchButton">
                        <Border x:Name="Root" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CacheMode="BitmapCache" Opacity="{TemplateBinding Opacity}" Padding="{TemplateBinding Padding}">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ColorAnimation Duration="0" To="{TemplateBinding Foreground}" Storyboard.TargetProperty="(Grid.Background).(SolidColorBrush.Color)" Storyboard.TargetName="SwitchBottom"/>
                                            <ColorAnimation Duration="0" To="{TemplateBinding Foreground}" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ThumbCenter"/>
                                            <DoubleAnimation Duration="0" To="0.3" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="CheckStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0:0:0.03" To="Unchecked"/>
                                        <VisualTransition GeneratedDuration="0:0:0.03" To="Checked"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Checked">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="61" Storyboard.TargetProperty="(TranslateTransform.X)" Storyboard.TargetName="BackgroundTranslation">
                                                <DoubleAnimation.EasingFunction>
                                                    <ExponentialEase EasingMode="EaseOut" Exponent="15"/>
                                                </DoubleAnimation.EasingFunction>
                                            </DoubleAnimation>
                                            <DoubleAnimation Duration="0" To="61" Storyboard.TargetProperty="(TranslateTransform.X)" Storyboard.TargetName="ThumbTranslation">
                                                <DoubleAnimation.EasingFunction>
                                                    <ExponentialEase EasingMode="EaseOut" Exponent="15"/>
                                                </DoubleAnimation.EasingFunction>
                                            </DoubleAnimation>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Dragging"/>
                                    <VisualState x:Name="Unchecked">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(TranslateTransform.X)" Storyboard.TargetName="BackgroundTranslation"/>
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(TranslateTransform.X)" Storyboard.TargetName="ThumbTranslation"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid x:Name="SwitchRoot" Background="Transparent" Height="95" Width="136">
                                <Grid x:Name="SwitchTrack" Width="89">
                                    <Grid x:Name="SwitchBottom" Background="{TemplateBinding SwitchForeground}" Height="34">
                                        <Rectangle x:Name="SwitchBackground" Fill="#FFFFFF" HorizontalAlignment="Center" Height="26" VerticalAlignment="Center" Width="82" Margin="4,4,3,4">
                                            <Rectangle.RenderTransform>
                                                <TranslateTransform x:Name="BackgroundTranslation"/>
                                            </Rectangle.RenderTransform>
                                        </Rectangle>
                                        <Border BorderBrush="{TemplateBinding Foreground}" BorderThickness="1">
                                            <Border BorderBrush="{TemplateBinding Background}" BorderThickness="3"/>
                                        </Border>
                                    </Grid>
                                    <Border x:Name="SwitchThumb" BorderBrush="{TemplateBinding Background}" BorderThickness="4" HorizontalAlignment="Left" Height="38" Margin="0" Width="28" Background="White">
                                        <Border.RenderTransform>
                                            <TranslateTransform x:Name="ThumbTranslation"/>
                                        </Border.RenderTransform>
                                    </Border>
                                </Grid>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="FixedToggleSwitchStyle" TargetType="toolkit:ToggleSwitch">
            <Setter Property="Background" Value="{StaticResource PhoneBackgroundBrush}"/>
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyLight}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="IsTabStop" Value="False"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="SwitchForeground" Value="{StaticResource PhoneAccentBrush}"/>
            <Setter Property="VerticalContentAlignment" Value="Top"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="toolkit:ToggleSwitch">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CacheMode="BitmapCache" Padding="{TemplateBinding Padding}">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0.3" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Header"/>
                                            <DoubleAnimation Duration="0" To="0.3" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Content"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid Margin="12,5,12,42">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <ContentControl x:Name="Header" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" Foreground="{StaticResource PhoneSubtleBrush}" FontSize="{StaticResource PhoneFontSizeNormal}" FontFamily="{StaticResource PhoneFontFamilyNormal}" HorizontalAlignment="Left" IsTabStop="False" Margin="-1,0,0,0" Opacity="{TemplateBinding Opacity}" VerticalAlignment="Bottom"/>
                                <ContentControl x:Name="Content" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsTabStop="False" Margin="-1,1,0,-7" Opacity="{TemplateBinding Opacity}" Grid.Row="1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                <toolkitPrimitives:ToggleSwitchButton x:Name="Switch" Background="{TemplateBinding Background}" Grid.Column="1" Margin="-22,-29,-24,-28" Opacity="{TemplateBinding Opacity}" Grid.RowSpan="2" SwitchForeground="{TemplateBinding SwitchForeground}" VerticalAlignment="Bottom" Style="{StaticResource FixedToggleSwitchButtonStyle}" Foreground="{TemplateBinding Foreground}"/>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>
    <shell:SystemTray.ProgressIndicator>
        <shell:ProgressIndicator x:Name="systemtray"/>
    </shell:SystemTray.ProgressIndicator>
    <!--LayoutRoot 是放置所有頁面的根資料格-->
    <Grid x:Name="LayoutRoot" Background="#FFF7F7F7" Margin="0,32,0,0" Loaded="LayoutRoot_Loaded">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.DataContext>
            <libViewModels:infoViewModel/>
        </Grid.DataContext>
        <!--TitlePanel 包含應用程式的名稱和頁面標題-->
        <StackPanel Grid.Row="0" Margin="12,5,0,28">
            <TextBlock Text="簡易初始設定" Style="{StaticResource PhoneTextNormalStyle}" Foreground="Black" FontSize="45"/>
        </StackPanel>

        <!--ContentPanel - 其他內容置於此-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,-30,12,0">
            <ScrollViewer>
            <StackPanel>
                <TextBlock Text="本頁提供初次或升級版本後的快速設定（約六項），您稍後可於下方齒輪按鈕中進行更多微調" TextWrapping="Wrap"/>
                    <TextBlock Text="請按下方下一步按鈕或倒退鍵結束設定" HorizontalAlignment="Center" Margin="0,5" Foreground="#FFC12B2B"/>
                    <StackPanel>
                    <StackPanel x:Name="bulletin">
                        <StackPanel.DataContext>
                            <libViewModels:dcViewModel/>
                        </StackPanel.DataContext>
                            <Border BorderThickness="0,0,0,1" BorderBrush="Black" Margin="0,3">
                                <TextBlock Text="歡迎訊息" FontSize="26"/>
                            </Border>
                            <TextBlock Text="歡迎使用本程式，在此提醒您，由於本程式內建油價預測與動態磚功能，建議不要關閉本程式的背景執行，另外，如果程式使用遇到問題，請隨時在下方功能列中叫出「聯絡開發者」，與我聯絡" TextWrapping="Wrap"/>
                            <Border BorderThickness="0,0,0,1" BorderBrush="Black" Margin="0,3">
                    <TextBlock Text="本次版本更新項目" FontSize="26"/>
                </Border>
                        <TextBlock Text="{Binding feedlist[0].content}" TextWrapping="Wrap"/>
                    </StackPanel>
                    <Border BorderThickness="0,0,0,1" BorderBrush="Black" Margin="0,3">
                    <TextBlock Text="系統設定（之後可點齒輪按鈕修改）" FontSize="26"/>
                </Border>
                <TextBlock Text="平日自動更新油價" FontSize="26" Foreground="Black" Margin="0,5,0,0"/>
                    <toolkit:ToggleSwitch x:Name="sfilterFPCC" Foreground="Black" Content="{Binding DataContext.autoUpdate, Converter={StaticResource filterConverter}, ElementName=LayoutRoot}" Style="{StaticResource FixedToggleSwitchStyle}" IsChecked="{Binding DataContext.autoUpdate, ElementName=LayoutRoot, Mode=TwoWay}">
                        <toolkit:ToggleSwitch.Header>
                            <TextBlock Text="啟動時自動更新" Foreground="Black"/>
                        </toolkit:ToggleSwitch.Header>
                    </toolkit:ToggleSwitch>
                    <TextBlock TextWrapping="Wrap" Foreground="Gray" Text="本設定只在平日有效，請注意，自動更新啟動下，若上一次和此次檢查只差五分鐘，將不會啟動更新"/>
                    <TextBlock Text="平日油價預測通知" FontSize="26" Foreground="Black" Margin="0,5,0,0"/>
                    <toolkit:ToggleSwitch Foreground="Black" Content="{Binding DataContext.dailynotifyEnable, Converter={StaticResource filterConverter}, ElementName=LayoutRoot}" Style="{StaticResource FixedToggleSwitchStyle}" IsChecked="{Binding DataContext.dailynotifyEnable, ElementName=LayoutRoot, Mode=TwoWay}">
                        <toolkit:ToggleSwitch.Header>
                            <TextBlock Text="通知當日油價預測" Foreground="Black"/>
                        </toolkit:ToggleSwitch.Header>
                    </toolkit:ToggleSwitch>
                    <TextBlock TextWrapping="Wrap" Foreground="Gray" Text="油價預測提醒會於平日跳出，詳細時間設定請進入程式後調整"/>
                        <TextBlock Text="抓取酒精汽油價格" x:Name="soapcontrol" FontSize="26" Foreground="Black" Margin="0,5,0,0">
                            <TextBlock.DataContext>
                                <libViewModels:cpViewModel/>
                            </TextBlock.DataContext>
                        </TextBlock>
                        <toolkit:ToggleSwitch Foreground="Black" Content="{Binding DataContext.soapUpdate, Converter={StaticResource filterConverter}, ElementName=soapcontrol}" Style="{StaticResource FixedToggleSwitchStyle}" IsChecked="{Binding DataContext.soapUpdate, ElementName=soapcontrol, Mode=TwoWay}" FontFamily="Portable User Interface">
                            <toolkit:ToggleSwitch.Header>
                                <TextBlock Text="更新酒精汽油價格" Foreground="Black"/>
                            </toolkit:ToggleSwitch.Header>
                        </toolkit:ToggleSwitch>
                    <TextBlock TextWrapping="Wrap" Foreground="Gray" Text="酒精汽油價格要另外連限至中油SOAP主機，可能會延長下載資料時間"/>
                    <Border BorderThickness="0,0,0,1" BorderBrush="Black" Margin="0,3">
                        <TextBlock Text="加油站過濾器（之後可點過濾器按鈕修改）" FontSize="26"/>
                    </Border>
                    <StackPanel x:Name="stationfilters">
                        <StackPanel.DataContext>
                            <libViewModels:stationViewModel/>
                        </StackPanel.DataContext>
                            <toolkit:ToggleSwitch Foreground="Black" Content="{Binding DataContext.sfilterInservice, Converter={StaticResource filterConverter}, ElementName=stationfilters}" Style="{StaticResource FixedToggleSwitchStyle}" IsChecked="{Binding DataContext.sfilterInservice, ElementName=stationfilters, Mode=TwoWay}">
                                <toolkit:ToggleSwitch.Header>
                                    <TextBlock Text="僅顯示營業中的加油站" Foreground="Black"/>
                                </toolkit:ToggleSwitch.Header>
                            </toolkit:ToggleSwitch>
                            <TextBlock Text="營業時間資料來自於台塑與中油網站，若與實際不符，請以實際為準" Foreground="DarkGray" TextWrapping="Wrap"/>
                            <toolkit:ToggleSwitch Foreground="Black" Content="{Binding DataContext.sfilterFPCC, Converter={StaticResource filterConverter}, ElementName=stationfilters}" Style="{StaticResource FixedToggleSwitchStyle}" IsChecked="{Binding DataContext.sfilterFPCC, ElementName=stationfilters, Mode=TwoWay}">
                            <toolkit:ToggleSwitch.Header>
                                <TextBlock Text="僅顯示中油加油站" Foreground="Black"/>
                            </toolkit:ToggleSwitch.Header>
                        </toolkit:ToggleSwitch>
                            <toolkit:ToggleSwitch Foreground="Black" Content="{Binding DataContext.sfilterDirect, Converter={StaticResource filterConverter}, ElementName=stationfilters}" Style="{StaticResource FixedToggleSwitchStyle}" IsChecked="{Binding DataContext.sfilterDirect, ElementName=stationfilters, Mode=TwoWay}">
                            <toolkit:ToggleSwitch.Header>
                                <TextBlock Text="僅顯示直營站" Foreground="Black"/>
                            </toolkit:ToggleSwitch.Header>
                        </toolkit:ToggleSwitch>
                    </StackPanel>
                    </StackPanel>
            </StackPanel>
            </ScrollViewer>
        </Grid>
        <Grid HorizontalAlignment="Left" Height="32" Margin="0,-32,0,0" VerticalAlignment="Top" Width="480" Background="{StaticResource PhoneAccentBrush}">
            <StackPanel x:Name="titlebar" Orientation="Horizontal" Margin="10,0,0,0">
            <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="台灣油價查詢" VerticalAlignment="Top" Width="132" Foreground="White"/>
            <TextBlock Text="{Binding DataContext.connectivity, Converter={StaticResource connectivitystringConverter}, ElementName=LayoutRoot}" Foreground="White"/>
            </StackPanel>
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>